package org.dllwh.mongodb.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

/**
 * 把今天最好的表现当作明天最新的起点．．～
 * <p>
 * Today the best performance as tomorrow the newest starter!
 *
 * @ClassName AjaxResult
 * @Description 统一结果返回
 * @Author: <a href="mailto:duleilewuhen@sina.com">独泪了无痕</a>
 * @Date 2025-05-09 22:50
 * @版本 V 1.0.1
 * @since JDK 17
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AjaxResult {
    // 是否响应成功
    private Boolean success = true;
    // 响应状态码
    private Integer code;
    // 提示信息
    private String message;
    // 响应数据
    private Object data;
    // 其他标识符（服务器当前时间、访问url、错误类型、错误的堆栈轨迹）
    private Map<String, Object> extraInfo;

    private AjaxResult(int resultCode, String message) {
        super();
        this.code = resultCode;
        this.message = message;
    }

    public static AjaxResult success() {
        return new AjaxResult(200, "操作成功！");
    }

    public static AjaxResult success(String message, Object data) {
        return new AjaxResult(true, 200, message, data, null);
    }

    public static AjaxResult fail() {
        return new AjaxResult(201, "操作失败！");
    }
}